//获取应用实例
const app = getApp();
// 引入AES.js
var baseJs = require("../../common/base.js");
Page({

  /**
   * 页面的初始数据
   */
  data: {
    whichData: [{
      id: "0",
      value: "功能异常",
      active: false
    },
    {
      id: "1",
      value: "意见建议",
      active: false
    },
    ],
    id: "",
    content: "",
    // 
    uid: "",
    userType: "",

  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    this.setData({
      uid: wx.getStorageSync('uid'),
      userType: wx.getStorageSync('userType')
    })
  },

  // choose
  choose: function (e) {
    console.log(e);
    var that = this;
    var whichData = this.data.whichData;
    var value = e.currentTarget.dataset.value;
    for (var i = 0, len = whichData.length; i < len; ++i) {
      if (whichData[i].value == value) {
        whichData[i].active = true;
      } else {
        whichData[i].active = false
      }
    }
    this.setData({
      whichData: whichData,
      id: e.currentTarget.dataset.id,
      value: value
    })
  },
  // textAreaBlur
  textAreaBlur: function (e) {
    this.setData({
      content: e.detail.value
    })
  },
  // handUp
  handUp: function () {
    var that = this;
    var uid = this.data.uid;
    var id = this.data.id;
    var content = this.data.content;
    console.log(id)
    if (id == "") {
      wx.showToast({
        title: "请选择反馈类型",
        icon: 'none',
        duration: 1500,
      })
      return false;
    }
    if (content == "") {
      wx.showToast({
        title: "请输入反馈内容",
        icon: 'none',
        duration: 1500,
      })
      return false;
    }
    console.log("method=AddFeedBackInfo&UID=" + uid + "&Content=" + content + "&Type=" + id);
    wx.request({
      url: baseJs.api + baseJs.encryUrl("method=AddFeedBackInfo&UID=" + uid + "&Content=" + content + "&Type=" + id),
      success: function (res) {
        var json = JSON.parse(baseJs.decryUrl(res.data));
        console.log(json);
        if (json.ResultFlag == 1) {
          wx.showToast({
            title: json.ResultMsg,
            icon: 'none',
            duration: 1500,
          })
          setTimeout(function () {
            wx.navigateBack({
              delta: 1
            })
          }, 1000)
        } else {
          wx.showToast({
            title: json.ResultMsg,
            icon: 'none',
            duration: 1500,
          })
        }
      }
    })
  },
})